package com.example.cadmin.utils;

import com.example.cadmin.Application;
import com.example.cadmin.entity.Host;
import com.example.cadmin.mapper.HostMapper;
import com.example.cadmin.utils.Netty.sendCmd;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.util.List;

/**
 * 获取温湿度后台定时器
 */
@Slf4j
public class TemperatureAndHumidity {


    /**
     * 获取温湿度
     */
    public void get() throws IOException {
        HostMapper hostMapper = Application.ac.getBean(HostMapper.class);
        sendCmd sendCmd = Application.ac.getBean(sendCmd.class);
        List<Host> hostList = hostMapper.selectList(null);
        for (Host host : hostList) {
            sendCmd.send("GETTEMP:",null,host.getIp());
        }
    }
}
